package com.tarena.practice.manage.vo;

import java.util.List;


public class PageUtils<T> {
	private Integer totalPage;
	private Integer currentPage;
	private Integer totalRow;
	private Integer pageSize;
	private Integer begin;
	private Integer listNum;
	private Integer type;
	private List<T> list;
	private String keyWord;
	private String order;
	private Integer optionI;
	
	
	public Integer getOptionI() {
		return optionI;
	}
	public void setOptionI(Integer optionI) {
		this.optionI = optionI;
	}
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	public Integer getBegin() {
		begin = (currentPage - 1) * pageSize;
		return begin;
	}
	public void setBegin(Integer begin) {
		this.begin = begin;
	}
	public String getOrder() {
		return order;
	}
	public void setOrder(String order) {
		this.order = order;
	}
	public Integer getPageSize() {
		return pageSize;
	}
	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}
	public Integer getTotalPage() {
		totalPage = (totalRow % pageSize == 0) ? (totalRow / pageSize) : (totalRow / pageSize) + 1;
		return totalPage;
	}
	public void setTotalPage(Integer totalPage) {
		this.totalPage = totalPage;
	}
	public List<T> getList() {
		return list;
	}
	public void setList(List<T> list) {
		this.list = list;
		this.listNum = list.size();
	}
	public String getKeyWord() {
		return keyWord;
	}
	
	public Integer getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(Integer currentPage) {
		this.currentPage = currentPage;
	}
	public Integer getTotalRow() {
		return totalRow;
	}
	public void setTotalRow(Integer totalRow) {
		this.totalRow = totalRow;
	}
	
	public void setKeyWord(String keyWord) {
		this.keyWord = ((keyWord==null||keyWord.length()==0||keyWord=="")
				?
				keyWord : "%" + keyWord + "%");
	}
	public Integer getListNum() {
		return listNum;
	}
	public void setListNum(Integer listNum) {
		this.listNum = listNum;
	}
	@Override
	public String toString() {
		return "PageUtils [totalPage=" + totalPage + ", currentPage=" + currentPage + ", totalRow=" + totalRow
				+ ", pageSize=" + pageSize + ", begin=" + begin + ", listNum=" + listNum + ", type=" + type + ", list="
				+ list + ", keyWord=" + keyWord + ", order=" + order + ", optionI=" + optionI + "]";
	}
	
	
	
}
